INCLUDE(srcs.cmake)

ADD_LIBRARY(imp_static_glibc STATIC ${LIBIMP_SRCS} ${EXT_STATIC_GLIBC_OBJS})
ADD_LIBRARY(imp_shared_glibc SHARED ${LIBIMP_SRCS} ${EXT_SHARED_GLIBC_OBJS})
ADD_LIBRARY(imp_static_uclibc STATIC ${LIBIMP_SRCS} ${EXT_STATIC_UCLIBC_OBJS})
ADD_LIBRARY(imp_shared_uclibc SHARED ${LIBIMP_SRCS} ${EXT_SHARED_UCLIBC_OBJS})
ADD_LIBRARY(imp_shared_glibc_audio_process SHARED ${LIBAUDIOPROCESS_SRCS} ${EXT_SHARED_GLIBC_AUDIO_OBJS})
ADD_LIBRARY(imp_shared_uclibc_audio_process SHARED ${LIBAUDIOPROCESS_SRCS} ${EXT_SHARED_UCLIBC_AUDIO_OBJS})

SET_TARGET_PROPERTIES(imp_static_glibc PROPERTIES
    OUTPUT_NAME "imp"
    ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-glibc
)

SET_TARGET_PROPERTIES(imp_shared_glibc PROPERTIES
    OUTPUT_NAME "imp"
    LINK_FLAGS "-lpthread -ldl"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-glibc
)

SET_TARGET_PROPERTIES(imp_static_uclibc PROPERTIES
    OUTPUT_NAME "imp"
    LINK_FLAGS "-muclibc -ldl"
    COMPILE_FLAGS "-muclibc"
    ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-uclibc
)

SET_TARGET_PROPERTIES(imp_shared_uclibc PROPERTIES
    OUTPUT_NAME "imp"
    LINK_FLAGS "-muclibc -lpthread -ldl"
    COMPILE_FLAGS "-muclibc"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-uclibc
)

SET_TARGET_PROPERTIES(imp_shared_glibc_audio_process PROPERTIES
    OUTPUT_NAME "audioProcess"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-glibc
)
SET_TARGET_PROPERTIES(imp_shared_uclibc_audio_process PROPERTIES
    OUTPUT_NAME "audioProcess"
    LINK_FLAGS "-muclibc"
    COMPILE_FLAGS "-muclibc"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-uclibc
)

INSTALL(TARGETS imp_static_glibc imp_shared_glibc
    ARCHIVE DESTINATION ${LIB_INSTALL_DIR_GLIBC}
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_GLIBC}
)

INSTALL(TARGETS imp_static_uclibc imp_shared_uclibc
    ARCHIVE DESTINATION ${LIB_INSTALL_DIR_UCLIBC}
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_UCLIBC}
)

INSTALL(TARGETS imp_shared_glibc_audio_process
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_GLIBC}
)

INSTALL(TARGETS imp_shared_uclibc_audio_process
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_UCLIBC}
)


ADD_CUSTOM_TARGET(VER ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/core/sys_interface.c)

ADD_CUSTOM_COMMAND(TARGET VER
    PRE_BUILD
    COMMAND touch ${CMAKE_CURRENT_SOURCE_DIR}/core/sys_interface.c
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    COMMENT "Update built time"
)
